Skip to content

siglent-sds: original driver fixes, USBTMC support#114

Closed
voneiden wants to merge 3 commits intosigrokproject:masterfrom
voneiden:siglent-sds-master
Closed

siglent-sds: original driver fixes, USBTMC support#114
voneiden wants to merge 3 commits intosigrokproject:masterfrom
voneiden:siglent-sds-master

Conversation

@voneiden
Copy link

@voneiden voneiden commented Jan 23, 2021

NOTE: Needs testing by someone who owns an older siglent scope.

Fixes a few memory leaks, one inconsistency with DATA_SOURCE and adds USBTMC support.

Addresses bugs

I've split off the eseries changes into a separate pull request #118 as that code should not require testing by someone with an older scope model.

@voneiden voneiden force-pushed the siglent-sds-master branch 5 times, most recently from 6aae055 to 08bfb7f Compare January 28, 2021 20:46
@voneiden voneiden marked this pull request as ready for review January 28, 2021 20:47
@voneiden voneiden changed the title siglent-sds: Improved E-series compatibility and general tweaks/fixes siglent-sds: Improved E-series compatibility, add USBTMC compatibility to all siglent-sds models and general tweaks/fixes Feb 2, 2021
@voneiden voneiden force-pushed the siglent-sds-master branch 4 times, most recently from f2cd6ad to 59972f4 Compare February 2, 2021 19:04
@voneiden
Copy link
Author

voneiden commented Feb 3, 2021

OK, I will probably refactor this PR into multiple smaller PR's for the sake of easier review.

@voneiden voneiden marked this pull request as draft February 5, 2021 23:38
@voneiden voneiden changed the title siglent-sds: Improved E-series compatibility, add USBTMC compatibility to all siglent-sds models and general tweaks/fixes siglent-sds: original driver fixes, USBTMC support and a new e-series implementation Feb 5, 2021
/* Do not change the order of entries. */
static const char *data_sources[] = {
"Display",
"Screen",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config_get for DATA_SOURCE returns "Screen" to the cli/pulseview, and since the enum is also DATA_SOURCE_SCREEN I decided to change these two occurrences of "Display" into "Screen".

@voneiden voneiden changed the title siglent-sds: original driver fixes, USBTMC support and a new e-series implementation siglent-sds: original driver fixes, USBTMC support Feb 6, 2021
@voneiden voneiden marked this pull request as ready for review February 6, 2021 15:35
@jr-oss
Copy link
Contributor

jr-oss commented May 18, 2021

Triggered by my bug report #1683 (https://sigrok.org/bugzilla/show_bug.cgi?id=1683) gsi prepared a fix for various memory leaks of the same kind, including the one in this PR.
https://repo.or.cz/libsigrok/gsi.git/commit/3d15878fbddd9dd6ac2c31da48ccee60ab473704

Matti, do you agree to the linked commitdiff, which will cause a conflict with your PR or do you prefer to keep it in your PR?

@voneiden
Copy link
Author

@jr-oss Seems good. I'll drop them from the PR.

@voneiden
Copy link
Author

But hey @jr-oss - that particular commit by gsi seems to be missing the initialization of a few pointers on the api.c side, see

f401971#diff-da08cdaf0b1d2848262a936247e81c8de384dfed1eda9be625e9bd8a61eb8916R298

the g_free calls for these two will end up trying to free random points in the memory unless I'm mistaken, danger danger?

@voneiden voneiden force-pushed the siglent-sds-master branch 2 times, most recently from f9b30f5 to 11d12fc Compare September 23, 2021 08:09
@LeSpocky
Copy link

Just built and tested this with a Siglent SPD3303C connected to a Linux host through USB, but it gives the same errors as latest release or master:

adahl@ada ~/sr % ./bin/sigrok-cli --show            
sr: scpi_usbtmc: USBTMC bulk in transfer error: LIBUSB_ERROR_TIMEOUT.
sr: scpi_usbtmc: USBTMC bulk in transfer error: LIBUSB_ERROR_TIMEOUT.
sr: scpi_usbtmc: USBTMC bulk in transfer error: LIBUSB_ERROR_TIMEOUT.
^C
adahl@ada ~/sr % ./bin/sigrok-cli --scan
sr: scpi_usbtmc: USBTMC bulk in transfer error: LIBUSB_ERROR_TIMEOUT.
sr: scpi_usbtmc: USBTMC bulk in transfer error: LIBUSB_ERROR_TIMEOUT.
sr: scpi_usbtmc: USBTMC bulk in transfer error: LIBUSB_ERROR_TIMEOUT.
sr: scpi_usbtmc: USBTMC bulk in transfer error: LIBUSB_ERROR_TIMEOUT.

Is this PR supposed to solve that? 🤔

@voneiden
Copy link
Author

@LeSpocky Correct me if I'm wrong, but I believe SPD3303C uses the scpi-pps driver instead of siglent-sds driver. Try verbose logging (--loglevel 4 or --loglevel 5).

Looks like same root cause anyway.

@LeSpocky
Copy link

I think you're right, I vaguely remember #77 addressing this and that's still open, too. Sorry for the noise.

FWIW, verbose log output (parts):

adahl@ada ~/sr % LD_LIBRARY_PATH=./lib ./bin/sigrok-cli -l 5 --scan            
sr: [00:00.000020] log: libsigrok loglevel set to 5.
sr: [00:00.000078] backend: libsigrok 0.6.0-git-1a0327f7/4:0:0.
sr: [00:00.000122] backend: Libs: glib 2.66.8 (rt: 2.66.8/6608:8), zlib 1.2.11, libzip 1.7.3, minilzo 2.10, libserialport 0.1.1/1:0:1 (rt: 0.1.1/1:0:1), libusb-1.0 1.0.24.11584 API 0x01000108, hidapi 0.10.1, bluez 5.55, libftdi 1.5.
sr: [00:00.000140] backend: Host: x86_64-pc-linux-gnu, little-endian.
sr: [00:00.000147] backend: SCPI backends: TCP, RPC, serial, USBTMC.
sr: [00:00.000152] backend: Firmware search paths:
sr: [00:00.000165] backend:  - /home/adahl/.local/share/sigrok-firmware
sr: [00:00.000169] backend:  - /home/adahl/sr/share/sigrok-firmware
sr: [00:00.000172] backend:  - /usr/local/share/sigrok-firmware
sr: [00:00.000176] backend:  - /usr/share/sigrok-firmware
sr: [00:00.000195] backend: Sanity-checking all drivers.
sr: [00:00.000203] backend: Sanity-checking all input modules.
sr: [00:00.000213] backend: Sanity-checking all output modules.
sr: [00:00.000219] backend: Sanity-checking all transform modules.
srd: libsigrokdecode loglevel set to 5.
…
sr: [00:10.128929] serial: No serial device specified.
sr: [00:10.128963] scpi_usbtmc: Found USBTMC device (VID:PID = 0483:7540, bus.address = 2.7).
sr: [00:10.128989] scpi: Opening USBTMC device usbtmc/2.7.
sr: [00:10.129032] usb: Found USB device (VID:PID = 0483:7540, bus.address = 2.7).
sr: [00:10.129053] usb: Trying to open USB device 2.7.
sr: [00:10.129084] usb: Opened USB device (VID:PID = 0483:7540, bus.address = 2.7).
sr: [00:10.129110] scpi_usbtmc: Interface 0 configuration 1.
sr: [00:10.129124] scpi_usbtmc: Bulk OUT EP 1
sr: [00:10.129141] scpi_usbtmc: Bulk IN EP 2
sr: [00:10.129393] scpi_usbtmc: Device capabilities: SCPI, TermChar, L4, T6, SR1, RL1, DT1
sr: [00:10.129410] scpi_usbtmc: Locking out local control.
sr: [00:10.129759] scpi_usbtmc: Failed to enter local lockout state: LIBUSB_ERROR_PIPE.
sr: [00:10.129841] scpi_usbtmc: Successfully sent SCPI command: '*IDN?'.
sr: [00:11.131941] scpi_usbtmc: USBTMC bulk in transfer error: LIBUSB_ERROR_TIMEOUT.
sr: [00:11.131995] scpi-pps: Couldn't get IDN response.
sr: [00:11.132003] scpi_usbtmc: Returning local control.
sr: [00:11.132122] scpi_usbtmc: Failed to clear local lockout state: LIBUSB_ERROR_PIPE.
sr: [00:11.132179] usb: Closed USB device 2.7.
sr: [00:11.140752] hwdriver: Scan found 0 devices (scpi-pps).
…
sr: [00:11.144609] serial: No serial device specified.
sr: [00:11.144636] scpi_usbtmc: Found USBTMC device (VID:PID = 0483:7540, bus.address = 2.7).
sr: [00:11.144649] scpi: Opening USBTMC device usbtmc/2.7.
sr: [00:11.144688] usb: Found USB device (VID:PID = 0483:7540, bus.address = 2.7).
sr: [00:11.144707] usb: Trying to open USB device 2.7.
sr: [00:11.144750] usb: Opened USB device (VID:PID = 0483:7540, bus.address = 2.7).
sr: [00:11.144758] scpi_usbtmc: Interface 0 configuration 1.
sr: [00:11.144762] scpi_usbtmc: Bulk OUT EP 1
sr: [00:11.144769] scpi_usbtmc: Bulk IN EP 2
sr: [00:11.145081] scpi_usbtmc: Device capabilities: SCPI, TermChar, L4, T6, SR1, RL1, DT1
sr: [00:11.145102] scpi_usbtmc: Locking out local control.
sr: [00:11.145506] scpi_usbtmc: Failed to enter local lockout state: LIBUSB_ERROR_PIPE.
sr: [00:11.145641] scpi_usbtmc: Successfully sent SCPI command: '*IDN?'.
sr: [00:12.147809] scpi_usbtmc: USBTMC bulk in transfer error: LIBUSB_ERROR_TIMEOUT.
sr: [00:12.147829] siglent-sds: Couldn't get IDN response, retrying.
sr: [00:12.147834] scpi_usbtmc: Returning local control.
sr: [00:12.148030] scpi_usbtmc: Failed to clear local lockout state: LIBUSB_ERROR_PIPE.
sr: [00:12.148074] usb: Closed USB device 2.7.
sr: [00:12.148082] usb: Trying to open USB device 2.7.
sr: [00:12.148126] usb: Opened USB device (VID:PID = 0483:7540, bus.address = 2.7).
sr: [00:12.148136] scpi_usbtmc: Interface 0 configuration 1.
sr: [00:12.148142] scpi_usbtmc: Bulk OUT EP 1
sr: [00:12.148148] scpi_usbtmc: Bulk IN EP 2
sr: [00:12.148400] scpi_usbtmc: Device capabilities: SCPI, TermChar, L4, T6, SR1, RL1, DT1
sr: [00:12.148418] scpi_usbtmc: Locking out local control.
sr: [00:12.148729] scpi_usbtmc: Failed to enter local lockout state: LIBUSB_ERROR_PIPE.
sr: [00:12.148885] scpi_usbtmc: Successfully sent SCPI command: '*IDN?'.
sr: [00:13.151084] scpi_usbtmc: USBTMC bulk in transfer error: LIBUSB_ERROR_TIMEOUT.
sr: [00:13.151133] siglent-sds: Couldn't get IDN response.
sr: [00:13.151150] scpi_usbtmc: Returning local control.
sr: [00:13.151357] scpi_usbtmc: Failed to clear local lockout state: LIBUSB_ERROR_PIPE.
sr: [00:13.151419] usb: Closed USB device 2.7.
sr: [00:13.159867] hwdriver: Scan found 0 devices (siglent-sds).

@voneiden voneiden closed this Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants